//
//  AlterImageController.m
//  ICrEAM
//
//  Created by mac on 16/11/15.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "AlterImageController.h"
#import "CheckCollectView.h"

@interface AlterImageController ()<UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UILabel *firstLabel;
@property (weak, nonatomic) IBOutlet UIImageView *firstImage;
@property (weak, nonatomic) IBOutlet UILabel *secondLabel;
@property (weak, nonatomic) IBOutlet UIImageView *secondImage;
@property (weak, nonatomic) IBOutlet UIImageView *thirdImage;
@property (weak, nonatomic) IBOutlet UILabel *thirdLabel;
@property (weak, nonatomic) IBOutlet UILabel *fourLabel;
@property (weak, nonatomic) IBOutlet UIImageView *fourImage;
@property (weak, nonatomic) IBOutlet UIImageView *big_image;
@property (weak, nonatomic) IBOutlet UIView *bgView;

@property (weak, nonatomic) IBOutlet CheckCollectView *collectionView;
@end

@implementation AlterImageController
- (void)viewDidLoad {
    [super viewDidLoad];

    if (self.isInner) {
        self.firstLabel.text=@"污渍";
        self.firstImage.image=[UIImage imageNamed:@"inner_1"];
        self.secondLabel.text=@"破损";
        self.secondImage.image=[UIImage imageNamed:@"inner_2"];
        self.thirdLabel.text=@"色斑";
        self.thirdImage.image=[UIImage imageNamed:@"inner_3"];
        self.fourLabel.text=@"变形";
        self.fourImage.image=[UIImage imageNamed:@"inner_4"];
    }
    NSString *bigImgStr=[ICrEAMTool isVW]?@"vwBig_placehold":@"skBig_placehold";
    [self.big_image sd_setImageWithURL:[NSURL URLWithString:self.bigUrlStr] placeholderImage:[UIImage imageNamed:bigImgStr]];
    self.collectionView.photoes=self.imageS;
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)showOnView:(UIWindow *)window
{
    CGRect frame = [UIScreen mainScreen].bounds;

    //    CGFloat height=with*
//        self.view.frame = CGRectMake(ScreenWidth-600, 200, 550, 450);
    self.view.frame=frame;
    [window addSubview:self.view];
    if (!IOS7_OR_LATER) {
        frame.origin.y = 20;
        frame.size.height-=20;
    }
    
}
- (void)setDismissBlock:(ICrEAMBlock)block
{
    if (block != dismissBlock) {
        dismissBlock = [block copy];
    }
}
//移除页面
- (void)removeAdImageView
{
    [UIView animateWithDuration:3.0f animations:^{
        
        
        self.bgView.alpha = 0.999f;
    } completion:^(BOOL finished) {
        [self.bgView removeFromSuperview];
        
        [self.view removeFromSuperview];
        if (dismissBlock) {
            dismissBlock();
        }
    }];
    
}
- (void)animationFinished{
    [self removeAdImageView];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    self.view.backgroundColor=[UIColor clearColor];
    CGContextRef contentext = UIGraphicsGetCurrentContext();
    
    [UIView beginAnimations:nil context:contentext];
    
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    
    [UIView setAnimationDuration:0.7];
    
    self.view.transform = CGAffineTransformMakeTranslation(self.view.width, 0);
    
    [UIView setAnimationDelegate:self];
    
    [UIView setAnimationDidStopSelector:@selector(animationFinished) ];
    
    [UIView commitAnimations];
}


@end
